<!DOCTYPE html>
<html lang="en" xmlns:layout="http://www.w3.org/1999/xhtml"
      layout:decorate="~{admin/adminJs}" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-model="http://www.w3.org/1999/xhtml">
<body layout:fragment="content">
<div id="from">
    <el-form :inline="true" label-width="100px" :model="user"  ref="user" :rules="rules"  style="padding: 15px;">

        <el-form-item label="用户名:" prop="userName" style="width: 45%;">
            <el-input v-model="user.userName" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="昵称:" prop="realName">
            <el-input v-model="user.realName" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="密码:" prop="password" style="width: 45%;">
            <el-input v-model="user.password" style="width: 250px;" show-password></el-input>
        </el-form-item>
        <el-form-item label="邮箱:" prop="email">
            <el-input v-model="user.email" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="电话:" prop="mobilePhone" style="width: 45%;">
            <el-input v-model="user.mobilePhone" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="专业:" prop="profession">
            <el-input v-model="user.profession" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="二级学院:" prop="secondaryCollege" style="width: 45%;">
            <el-input v-model="user.secondaryCollege" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="头像:" prop="img">
            <el-input v-model="user.img" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="个性签名:" prop="autograph" style="width: 45%;">
            <el-input v-model="user.autograph" style="width: 250px;"></el-input>
        </el-form-item>
        <el-form-item label="学校名称:" prop="deptId">
            <el-input v-model="user.deptId" style="width: 250px;"></el-input>
        </el-form-item>
        <el-row style="text-align: center">
            <el-button type="primary" @click="onSubmit">保存</el-button>
            <el-button @click="resetForm('user')">重置</el-button>
            <el-button @click="cancel()">取消</el-button>
        </el-row>
    </el-form>
</div>
<script>

    var id=RequestUtils.getId();

    var vm=new Vue({
        el: '#from',
        data:function () {
            var user=ajaxGet("/admin/user/user/read",{id:id});
            var rules={
                /*id:ValidateUtils.required('请输入id!'),*/
                userName:ValidateUtils.required('请输入用户名!'),
                realName:ValidateUtils.required('请输入用户昵称!'),
                password:ValidateUtils.required('请输入密码!'),
                /*searchName:ValidateUtils.required('请输入查找名称!'),
                img:ValidateUtils.required('请输入头像!'),
                autograph:ValidateUtils.required('请输入个性签名!'),
                profession:ValidateUtils.required('请输入专业!'),
                secondaryCollege:ValidateUtils.required('请输入二级学院!'),
                email:ValidateUtils.required('请输入!'),
                mobilePhone:ValidateUtils.required('请输入!'),
                deptId:ValidateUtils.required('请输入单位学校!'),*/
            };
            return {
                user:user,
                rules:rules
            };
        },
        methods:{
            onSubmit:function () {
                this.$refs['user'].validate(function(valid) {
                    if (valid) {
                        EasyuiUtils.confirmSave("/admin/user/user/save",vm.user,function () {
                            vm.closeParentDialog(true);
                        });
                    } else {
                       EasyuiUtils.alert('请输入必填项!');
                    }
                });

            },
            cancel:function () {
                vm.closeParentDialog();
            },
            closeParentDialog:function(isRefresh){
                window.parent.closeDialog(isRefresh);
            },
            resetForm:function(formName) {
                this.$refs[formName].resetFields();
            }
        }
    });
</script>

</body>
</html>